<script setup>
  import {ref} from 'vue'
  const imgList = ref([
    {id:1,src:'src/assets/p-1.jpg',title:'第一张图片'},
    {id:2,src:'src/assets/p-1.jpg',title:'第二张图片'},
    {id:3,src:'src/assets/p-1.jpg',title:'第三张图片'},
    {id:4,src:'src/assets/p-1.jpg',title:'第四张图片'},
    {id:4,src:'src/assets/p-1.jpg',title:'第五张图片'}
  ])
  console.log(imgList.value)
</script>

<template>
  <div class="block text-center ">
<!--    <span class="demonstration">Switch when indicator is hovered (default)</span>-->
    <el-carousel height="320px" type="card">
      <el-carousel-item v-for="(item,index) in imgList" :key="item">
        <div class="box">
          <div class="box-img">
            <img :src="item.src">
          </div>
          <div class="box-title">
            <h3 class="small justify-center" text="2xl">{{ item.title }}</h3>
          </div>
        </div>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<style lang="scss" scoped>
$heigh: 320px;

.block{
  width: 100%;
}
.demonstration {
  color: var(--el-text-color-secondary);
}

.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height:$heigh ;
  margin: 0;
  text-align: center;
}

.el-carousel__item{

}
.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf00;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce600;
}

.box{
  position: relative;
  .box-img{
    width: 100%;
    position: absolute;
    z-index: 1;
    height: $heigh;
    background-color: #f8f8f800;
    img{
      height: $heigh;
    }
  }
  .box-title{
    width: 100%;
    height: 100%;
    color: #f2f2f2;
    position: absolute;
    top: 50%;
    bottom: 50%;
    margin: 0 auto;
    z-index: 2;
  }
}
</style>
